<html>
    <head>
        <script src="../../resources/gc.js"></script>
        <script>
            if (window.testRunner) {
                testRunner.dumpAsText();
                testRunner.waitUntilDone();
            }

            function runTest()
            {
                iteratorRoot = document.createElement('div');
                element = iteratorRoot.appendChild(document.createElement('div'));
                element.appendChild(document.createElement('div'));

                iterator = document.createNodeIterator(iteratorRoot, -1);
                iterator.nextNode(); iterator.nextNode(); iterator.nextNode();
                iterator.previousNode();

                iteratorRoot.removeChild(element);

                otherDocument = document.implementation.createHTMLDocument();
                otherDocument.body.appendChild(iteratorRoot);

                delete iterator;
                gc();
                div = document.body.appendChild(document.createElement('div'));
                document.body.removeChild(div);
                gc();

                if (window.testRunner)
                    testRunner.notifyDone();
            }
        </script>
    </head>
    <body onload="runTest()">
        Test passes if it does not crash.
    </body>
</html>
